from selenium import webdriver
from bs4 import BeautifulSoup
import time
import requests
import os
from concurrent.futures import ThreadPoolExecutor

driver = webdriver.Firefox()
# 打开指定地址
driver.get("https://www.12306.cn/index/")

driver.find_element_by_id("fromStationText").clear()
driver.find_element_by_id("fromStationText").click()
driver.find_element_by_id("fromStationText").sendKeys("北京")
o_InputSelect=driver.find_elements_by_class_name("ralign")
for i in o_InputSelect:                                   
    if i.text == "北京":
        i.click()
        break
driver.find_element_by_id("toStationText").clear()
driver.find_element_by_id("toStationText").click()
driver.find_element_by_id("toStationText").sendKeys("上海")
o_Select=driver.find_elements_by_class_name("ralign")
for i in o_Select:                                   
    if i.text == "上海":
        i.click()
        break
driver.find_element_by_id("search_one").click()

# 指向弹出页面
driver.switch_to.window(driver.window_handles[-1])
        # 解析网页
print(driver.page_source)
